home *** CD-ROM | disk | FTP | other *** search
/ Internet.Works 41 / Issue 41.iso / pc / PCSoftware / Netscape 6 Official Release / nim.xpi / bin / chrome / aim.jar / content / aim / Aim.js < prev    next >
Encoding:
Text File  |  2000-10-10  |  4.1 KB  |  151 lines

  1. var IMServiceClass = Components.classes['@netscape.com/aim/IMManager;1'];
  2. var pIIMManager  = IMServiceClass.getService(Components.interfaces.nsIIMManager);
  3.  
  4. var RDFClass = Components.classes["@mozilla.org/rdf/rdf-service;1"];
  5. var RDF = RDFClass.getService(Components.interfaces.nsIRDFService);
  6. var AimDataSource = RDF.GetDataSource("rdf:AIM");
  7.  
  8. var AimSession = RDF.GetResource("NC:AIM/Session");
  9. var SessionState = RDF.GetResource("http://home.netscape.com/NC-rdf#OnlineState");
  10.  
  11.  
  12. function aimGetArgs(data)
  13. {
  14.     var args = new Object();
  15.     var pairs = data.split(",");
  16.     dump("GetArgs: argument: {" + data + "}\n");
  17.  
  18.     for (var i = pairs.length - 1; i >= 0; i--)
  19.     {
  20.         var pos = pairs[i].indexOf('=');
  21.         if (pos == -1)
  22.             continue;
  23.         var argname = pairs[i].substring(0, pos);
  24.         var argvalue = pairs[i].substring(pos + 1);
  25.         if (argvalue.charAt(0) == "'" && argvalue.charAt(argvalue.length - 1) == "'")
  26.             args[argname] = argvalue.substring(1, argvalue.length - 1);
  27.         else
  28.             args[argname] = unescape(argvalue);
  29.     }
  30.     return args;
  31. }
  32.  
  33. function aimString(name)
  34. {
  35.  
  36.     var pIStringBundle = pIIMManager.QueryInterface(Components.interfaces.nsIStringBundle);
  37.     if (pIStringBundle)
  38.         return pIStringBundle.GetStringFromName(name);
  39.     return "";
  40. }
  41.  
  42. function aimErrorBox(errorText)
  43. {
  44.     top.alert(errorText);
  45. }
  46.  
  47. /* Global menu commands. Menu commands that might be useful to multiple apps go here */
  48.  
  49. function aimCmdNewBrowser(url)
  50. {
  51.     var Browser_pref=null;
  52.     try
  53.     {
  54.           Browser_pref = Components.classes["@mozilla.org/preferences;1"];
  55.           if (Browser_pref)       Browser_pref = Browser_pref.getService();
  56.           if (Browser_pref)       Browser_pref = Browser_pref.QueryInterface(Components.interfaces.nsIPref);
  57.     }
  58.     catch (ex)
  59.     {
  60.           dump("failed to get prefs service!\n");
  61.           Browser_pref = null;
  62.     }
  63.  
  64.     if (Browser_pref.GetBoolPref("network.protocols.useSystemDefaults"))
  65.      {
  66.         var uri = Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIURI); 
  67.         uri.spec=url;
  68.         aimAdminManager().LoadDefaultBrowser(uri);
  69.         }
  70.     else
  71.         window.openDialog( "chrome://navigator/content/navigator.xul", "_blank", "chrome,all,dialog=no", url);
  72. }
  73.  
  74.  
  75. function aimCmdNewEmail()
  76. {
  77.     dump("Implement Menu Command cmdNewEmail()\n");
  78.  
  79.     openDialog("chrome://messenger/content/messengercompose/messengercompose.xul", "");
  80.     dump( "Leaving aimCmdNewEmail()\n" );
  81.  
  82. }
  83.  
  84. // this function tries to find where the groups data in the tree starts, 
  85. // and returns the node, else null. 
  86.  
  87. function aimBuddyTreeFindGroups( tree )
  88. {
  89.     if ( !tree ) {
  90.         return( null);
  91.     }
  92.  
  93.     else if ( !tree.childNodes )
  94.     {
  95.         return( null );
  96.     }
  97.  
  98.     for ( var i = 0; i < tree.childNodes.length; i++ ) {
  99.         if ( tree.childNodes[i].nodeName == "treechildren" ) {
  100.             return( tree.childNodes[i].childNodes );
  101.         }
  102.     }
  103.     return( null );
  104. }
  105.  
  106. function aimGlobalCmdStartupWizard()
  107. {
  108.     var windowManager = Components.classes['@mozilla.org/rdf/datasource;1?name=window-mediator'].getService();
  109.  
  110.     var    windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator);
  111.  
  112.     var topWindow = windowManagerInterface.getMostRecentWindow("Aim:StartupWizard");
  113.   if(topWindow)
  114.     topWindow.focus();
  115.   else
  116.     window.openDialog('chrome://aim/content/migrationWizard.xul','CPW','chrome,titlebar,resizable=yes',document);
  117. }
  118.  
  119. function ClearMenuList( menulist )
  120. {
  121.     if ( menulist ) {
  122.         menulist.selectedItem = null;
  123.         while( menulist.firstChild )
  124.             menulist.removeChild( menulist.firstChild );
  125.     }
  126. }
  127.  
  128. function AppendStringToMenulist(menulist, string)
  129. {
  130.   if (menulist) {
  131.     var menupopup = menulist.firstChild;
  132.     // May not have any popup yet -- so create one
  133.     if (!menupopup) {
  134.       menupopup = document.createElement("menupopup");
  135.       if (menupopup)
  136.         menulist.appendChild(menupopup);
  137.       else {
  138.         dump("Failed to create menupoup\n");
  139.         return null;
  140.       }
  141.     }
  142.     menuItem = document.createElement("menuitem");
  143.     if (menuItem) {
  144.       menuItem.setAttribute("value", string);
  145.       menupopup.appendChild(menuItem);
  146.       return menuItem;
  147.     }
  148.   }
  149.   return null;
  150. }
  151.